package com.why.constantpool;

import com.why.basictype.U2;

import java.io.InputStream;

/**
 * @author by xiaoTian
 * @date 2022/5/21.
 */
public class ConstantFieldRefInfo extends ConstantPoolInfo {
    public short classIndex;
    public short nameAndTypeIndex;

    public ConstantFieldRefInfo(byte tag){
        setTag(tag);
    }

    @Override
    public void read(InputStream inputStream) {
        U2 classIndexU = U2.read(inputStream);
        U2 nameAndTypeIndexU = U2.read(inputStream);
        this.classIndex = classIndexU.getValue();
        this.nameAndTypeIndex = nameAndTypeIndexU.getValue();
    }

    @Override
    public String toString() {
        return "ConstantFieldRefInfo{" +
                "classIndex=" + classIndex +
                ", nameAndTypeIndex=" + nameAndTypeIndex +
                '}';
    }
}
